function excluirParticipante(indParticipante){	
	document.getElementById('horaReuniao_participanteExcluir').value = document.getElementById('horaReuniao').value;
	document.getElementById('dataReuniao_participanteExcluir').value = document.getElementsByName('dataReuniao')[0].value;
	document.getElementById('localReuniao_participanteExcluir').value = document.getElementById('localReuniao').value;
	document.getElementById('tipoReuniao_participanteExcluir').value = dijit.byId('tipoReuniao').value;
	document.getElementById('descricaoReuniao_participanteExcluir').value = document.getElementById('descricaoReuniao').value;
	document.getElementById('encaminhamentoReuniao_participanteExcluir').value = document.getElementById('encaminhamentoReuniao').value;
	document.getElementById('idEncaminhamentoReuniao_participanteExcluir').value = document.getElementById('idEncaminhamento').value;
	document.getElementById('indParticipanteExcluir').value = indParticipante;
	document.getElementById('excluirParticipanteForm').submit();
}

function excluirArtefato(indArtefato){
	document.getElementById('horaReuniao_artefatoExcluir').value = document.getElementById('horaReuniao').value;
	document.getElementById('dataReuniao_artefatoExcluir').value = document.getElementsByName('dataReuniao')[0].value;
	document.getElementById('localReuniao_artefatoExcluir').value = document.getElementById('localReuniao').value;
	document.getElementById('tipoReuniao_artefatoExcluir').value = dijit.byId('tipoReuniao').value;
	document.getElementById('descricaoReuniao_artefatoExcluir').value = document.getElementById('descricaoReuniao').value;
	document.getElementById('encaminhamentoReuniao_artefatoExcluir').value = document.getElementById('encaminhamentoReuniao').value;
	document.getElementById('idEncaminhamentoReuniao_participanteExcluir').value = document.getElementById('idEncaminhamento').value;
	document.getElementById('indArtefatoExcluir').value = indArtefato;
	document.getElementById('excluirArtefatoForm').submit();
}

function cadastraParticipante(){	
	document.getElementById('horaReuniao_participanteAdd').value = document.getElementById('horaReuniao').value;
	document.getElementById('dataReuniao_participanteAdd').value = document.getElementsByName('dataReuniao')[0].value;
	document.getElementById('localReuniao_participanteAdd').value = document.getElementById('localReuniao').value;
	document.getElementById('tipoReuniao_participanteAdd').value = dijit.byId('tipoReuniao').value;
	document.getElementById('descricaoReuniao_participanteAdd').value = document.getElementById('descricaoReuniao').value;
	document.getElementById('encaminhamentoReuniao_participanteAdd').value = document.getElementById('encaminhamentoReuniao').value;
	document.getElementById('idEncaminhamentoReuniao_participanteExcluir').value = document.getElementById('idEncaminhamento').value;
	
	participanteForm = dijit.byId("addParticipanteForm");
	participanteForm.validate();
	participanteForm.submit();
	
}

function downloadArtefato(indArtefato){
	document.getElementById('indArtefatoDownload').value = indArtefato;
	document.getElementById('downloadArtefatoForm').submit();
}


function sendUpload(form){	
	document.getElementById('horaReuniao_artefatoAdd').value = document.getElementById('horaReuniao').value;
	document.getElementById('dataReuniao_artefatoAdd').value = document.getElementsByName('dataReuniao')[0].value;
	document.getElementById('localReuniao_artefatoAdd').value = document.getElementById('localReuniao').value;
	document.getElementById('tipoReuniao_artefatoAdd').value = dijit.byId('tipoReuniao').value;
	document.getElementById('descricaoReuniao_artefatoAdd').value = document.getElementById('descricaoReuniao').value;
	document.getElementById('encaminhamentoReuniao_artefatoAdd').value = document.getElementById('encaminhamentoReuniao').value;
	document.getElementById('idEncaminhamentoReuniao_participanteExcluir').value = document.getElementById('idEncaminhamento').value;
	form.submit();
}


function loadAjax(indParticipante){
	var url = "/reuniao/interno/reuniao/participante.editar";
	xmlhttp = null;
	if(window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
  		xmlhttp = new XMLHttpRequest();
  	}
	else {// code for IE6, IE5
  		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  	}
	xmlhttp.open("POST", url, true);
	//xmlhttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
	xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	xmlhttp.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");

	xmlhttp.onreadystatechange = XMLHttpRequestChange;
	xmlhttp.send("indParticipante="+indParticipante);
}

function XMLHttpRequestChange(){
	if (xmlhttp.readyState == 4){// 4 = "loaded"
		if (xmlhttp.status == 200){// 200 = "OK"
			var xmlDoc = xmlhttp.responseXML;
			
			if(xmlDoc.getElementsByTagName("nome")[0].firstChild != null)
				document.getElementById("nome_participante").value = xmlDoc.getElementsByTagName("nome")[0].firstChild.nodeValue;
			else
				document.getElementById("nome_participante").value = "";
			
			if(xmlDoc.getElementsByTagName("cargo")[0].firstChild != null)
				document.getElementById("cargo").value = xmlDoc.getElementsByTagName("cargo")[0].firstChild.nodeValue;
			else
				document.getElementById("cargo").value = "";
			
			if(xmlDoc.getElementsByTagName("celular")[0].firstChild != null)
				document.getElementById("celular").value = xmlDoc.getElementsByTagName("celular")[0].firstChild.nodeValue;
			else
				document.getElementById("celular").value = "";
			
			if(xmlDoc.getElementsByTagName("telefone")[0].firstChild != null)
				document.getElementById("telefone").value = xmlDoc.getElementsByTagName("telefone")[0].firstChild.nodeValue;
			else
				document.getElementById("telefone").value = "";
			
			if(xmlDoc.getElementsByTagName("observacao")[0].firstChild != null)
				document.getElementById("observacao").value = xmlDoc.getElementsByTagName("observacao")[0].firstChild.nodeValue;
			else
				document.getElementById("observacao").value = "";
			
			if(xmlDoc.getElementsByTagName("indice")[0].firstChild != null)
				document.getElementById("indParticipante").value = xmlDoc.getElementsByTagName("indice")[0].firstChild.nodeValue;
			else
				document.getElementById("indParticipante").value = "";
			
			if(xmlDoc.getElementsByTagName("id")[0].firstChild != null)
				document.getElementById("idParticipante").value = xmlDoc.getElementsByTagName("id")[0].firstChild.nodeValue;
			else
				document.getElementById("idParticipante").value = "";
			
			dijit.byId("divAdicionarParticipante").show();
		}
  		else {
    		alert("Problem retrieving XML data:" + xmlhttp.statusText);
   		}
	}
}

function visualizar(indParticipante){
	loadAjax(indParticipante);
	
}

function salvarReuniao(){	

	if (validaFormulario(document.alterarForm)){
		document.getElementById("divAjaxLoader").style.display = "block";
		document.alterarForm.submit();
	}
}

function inserirRelatorioAtual(idNegocio){	
	form = document.getElementById("alterarForm");
	
	form.action = "${pageContext.general.APP_PATH}relatorio.request";
	form.submit();	
}
